
import datetime

class Sensor:
    def __init__(self, data: dict, time: datetime.datetime = None):
        self.data = data
        if time is None:
            self.time = datetime.datetime.now()
        else:
            self.time = time

    def to_dict(self):
        return {
            "data": self.data,
            "time": self.time,
        }

    @classmethod
    def from_dict(cls, dict:dict):
        return cls(
            dict["data"],
            dict["time"],
        )

class SensorDirection:
    def __init__(self, data: dict, time: datetime.datetime = None):
        self.data = data
        if time is None:
            self.time = datetime.datetime.now()
        else:
            self.time = time

    def to_dict(self):
        return {
            "data": self.data,
            "time": self.time,
        }

    @classmethod
    def from_dict(cls, dict:dict):
        return cls(
            dict["data"],
            dict["time"],
        )